<gm:page title="News Map">
   <style>
a:link {color: #BC7228;text-decoration: none;}
a:hover {color: #3B4F6A;text-decoration: none;}
a:visited {color: #BC7228;text-decoration: none;}
a:active {color: #3B4F6A;text-decoration: none;}
  </style>
<link href="" rel="stylesheet" type="text/css" />
	<div style="width:980px;height:800px" align="left">
   <gm:tabs target="myContainer"/>
   <gm:container id="myContainer">    
      <!--include Tag,google map,a template when event happens-->
	
      <gm:section id="topNews" title="地区头条新闻">
                <gm:map id="mapNews" data="${dataLocation}" latref="atom:lat"
					lngref="atom:long" infotemplate="templateMap">
					<gm:handleEvent src="mapNews" event="select"
						execute="updateFeed();" />
					  <!--选择城市后，加入此城市的RSS新闻-->                                                                              
		</gm:map>
                        
                                        <gm:list id="listNewsTop5"
						pagesize="5" template="templateListNews">
						<gm:handleEvent event="repaint" execute="updateMap();" />
					</gm:list>     <!--在图框中显示出新闻的标题和链接信息-->
                        
       </gm:section>
    </gm:container>	
	</div>

	<gm:template id="templateListNews">	     
              <div repeat="true">        
	   <gm:html ref="atom:content" />		
            </div>	
	</gm:template>     <!--在select事件发生后图框中显示newslist-->


	<gm:template id="templateMap">
		<div id="td_newsList" style="width:300px;height:120px" align="left">
		</div>
	</gm:template>   <!--定义图框的格式-->


	<!-- 要显示的各城市的地理经纬度信息 -->
	<gm:data id="dataLocation">
		<atom:feed>
			<atom:entry>
				<atom:id>1</atom:id>
				<atom:title>北京</atom:title>
				<atom:lat>39.9</atom:lat>
				<atom:long>116.4</atom:long>
			</atom:entry>


			<atom:entry>
				<atom:id>2</atom:id>
				<atom:title>上海</atom:title>
				<atom:lat>31.2</atom:lat>
				<atom:long>121.4</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>3</atom:id>
				<atom:title>天津</atom:title>
				<atom:lat>39.1</atom:lat>
				<atom:long>117.2</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>4</atom:id>
				<atom:title>重庆</atom:title>
				<atom:lat>29.5</atom:lat>
				<atom:long>106.5</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>5</atom:id>
				<atom:title>广州</atom:title>
				<atom:lat>23.1</atom:lat>
				<atom:long>113.2</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>6</atom:id>
				<atom:title>石家庄</atom:title>
				<atom:lat>38</atom:lat>
				<atom:long>114.4</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>7</atom:id>
				<atom:title>沈阳</atom:title>
				<atom:lat>41.8</atom:lat>
				<atom:long>123.4</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>8</atom:id>
				<atom:title>长春</atom:title>
				<atom:lat>43.9</atom:lat>
				<atom:long>125.3</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>9</atom:id>
				<atom:title>兰州</atom:title>
				<atom:lat>36</atom:lat>
				<atom:long>103.7</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>10</atom:id>
				<atom:title>太原</atom:title>
				<atom:lat>37.8</atom:lat>
				<atom:long>112.5</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>11</atom:id>
				<atom:title>成都</atom:title>
				<atom:lat>30.6</atom:lat>
				<atom:long>104.1</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>12</atom:id>
				<atom:title>西安</atom:title>
				<atom:lat>34.2</atom:lat>
				<atom:long>108.9</atom:long>
			</atom:entry>

			<atom:entry>
				<atom:id>13</atom:id>
				<atom:title>郑州</atom:title>
				<atom:lat>34.7</atom:lat>
				<atom:long>113.6</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>14</atom:id>
				<atom:title>济南</atom:title>
				<atom:lat>36.6</atom:lat>
				<atom:long>117</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>15</atom:id>
				<atom:title>长沙</atom:title>
				<atom:lat>28.2</atom:lat>
				<atom:long>112.9</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>16</atom:id>
				<atom:title>武汉</atom:title>
				<atom:lat>30.5</atom:lat>
				<atom:long>114.2</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>17</atom:id>
				<atom:title>南昌</atom:title>
				<atom:lat>28.6</atom:lat>
				<atom:long>115.9</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>18</atom:id>
				<atom:title>南京</atom:title>
				<atom:lat>32</atom:lat>
				<atom:long>118.7</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>19</atom:id>
				<atom:title>杭州</atom:title>
				<atom:lat>30.2</atom:lat>
				<atom:long>120.1</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>20</atom:id>
				<atom:title>合肥</atom:title>
				<atom:lat>31.8</atom:lat>
				<atom:long>117.3</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>21</atom:id>
				<atom:title>福州</atom:title>
				<atom:lat>26</atom:lat>
				<atom:long>119.3</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>22</atom:id>
				<atom:title>南宁</atom:title>
				<atom:lat>22.8</atom:lat>
				<atom:long>108.3</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>23</atom:id>
				<atom:title>贵阳</atom:title>
				<atom:lat>26.6</atom:lat>
				<atom:long>106.7</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>24</atom:id>
				<atom:title>香港</atom:title>
				<atom:lat>21.23</atom:lat>
				<atom:long>115.12</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>25</atom:id>
				<atom:title>澳门</atom:title>
				<atom:lat>21.33</atom:lat>
				<atom:long>115.07</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>26</atom:id>
				<atom:title>海口</atom:title>
				<atom:lat>20</atom:lat>
				<atom:long>110.3</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>27</atom:id>
				<atom:title>台北</atom:title>
				<atom:lat>25</atom:lat>
				<atom:long>121.5</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>28</atom:id>
				<atom:title>昆明</atom:title>
				<atom:lat>25</atom:lat>
				<atom:long>102.7</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>29</atom:id>
				<atom:title>呼和浩特</atom:title>
				<atom:lat>40.8</atom:lat>
				<atom:long>111.7</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>30</atom:id>
				<atom:title>西宁</atom:title>
				<atom:lat>36.6</atom:lat>
				<atom:long>101.8</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>31</atom:id>
				<atom:title>银川</atom:title>
				<atom:lat>38.4</atom:lat>
				<atom:long>106.2</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>32</atom:id>
				<atom:title>乌鲁木齐</atom:title>
				<atom:lat>43.8</atom:lat>
				<atom:long>87.6</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>33</atom:id>
				<atom:title>拉萨</atom:title>
				<atom:lat>29.6</atom:lat>
				<atom:long>91.1</atom:long>
			</atom:entry>
			<atom:entry>
				<atom:id>34</atom:id>
				<atom:title>哈尔滨</atom:title>
				<atom:lat>45.7</atom:lat>
				<atom:long>126.6</atom:long>
			</atom:entry>
		</atom:feed>
	</gm:data>

	<script>



var listModule;

function updateFeed(){
<!--当在地图中点击某个城市事件发生后，执行此函数，得到此城市的RSS新闻-->

var titleGPath = new GPath("atom:title");
var entry = google.mashups.getObjectById('mapNews').getSelectedEntry();
    if (entry == null) { return; }

var title= titleGPath.getValue(entry);

var rssUrl;
<!--引用Baidu的RSS新闻源-->

if(title=="北京"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=0&name=%B1%B1%BE%A9&tn=rss";

}else if(title=="上海"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=2354&name=%C9%CF%BA%A3&tn=rss";

}else if(title=="天津"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=125&name=%CC%EC%BD%F2&tn=rss";

}else if(title=="重庆"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=6425&name=%D6%D8%C7%EC&tn=rss";

}else if(title=="广州"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=5495&name=%B9%E3%B6%AB&tn=rss";

}else if(title=="石家庄"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=250&name=%BA%D3%B1%B1&tn=rss";

}else if(title=="沈阳"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=1481&name=%C1%C9%C4%FE&tn=rss";

}else if(title=="长春"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=1783&name=%BC%AA%C1%D6&tn=rss";

}else if(title=="兰州"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=8534&name=%B8%CA%CB%E0&tn=rss";

}else if(title=="太原"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=812&name=%C9%BD%CE%F7&tn=rss";

}else if(title=="成都"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=6692&name=%CB%C4%B4%A8&tn=rss";

}else if(title=="西安"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=8205&name=%C9%C2%CE%F7&tn=rss";

}else if(title=="郑州"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=4371&name=%BA%D3%C4%CF&tn=rss";

}else if(title=="济南"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=3996&name=%C9%BD%B6%AB&tn=rss";

}else if(title=="长沙"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=5161&name=%BA%FE%C4%CF&tn=rss";

}else if(title=="武汉"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=4811&name=%BA%FE%B1%B1&tn=rss";

}else if(title=="南昌"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=3636&name=%BD%AD%CE%F7&tn=rss";

}else if(title=="南京"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=2493&name=%BD%AD%CB%D5&tn=rss";

}else if(title=="杭州"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=2809&name=%D5%E3%BD%AD&tn=rss";

}else if(title=="合肥"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=3072&name=%B0%B2%BB%D5&tn=rss";

}else if(title=="福州"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=3372&name=%B8%A3%BD%A8&tn=rss";

}else if(title=="南宁"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=5886&name=%B9%E3%CE%F7&tn=rss";

}else if(title=="贵阳"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=7230&name=%B9%F3%D6%DD&tn=rss";

}else if(title=="香港"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=9337&name=%CF%E3%B8%DB&tn=rss";

}else if(title=="澳门"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=9436&name=%B0%C4%C3%C5&tn=rss";

}else if(title=="海口"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=6245&name=%BA%A3%C4%CF&tn=rss";

}else if(title=="台北"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=9442&name=%CC%A8%CD%E5&tn=rss";

}else if(title=="昆明"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=7527&name=%D4%C6%C4%CF&tn=rss";

}else if(title=="呼和浩特"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=1167&name=%C4%DA%C3%C9%B9%C5&tn=rss";

}else if(title=="西宁"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=8782&name=%C7%E0%BA%A3&tn=rss";

}else if(title=="银川"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=8907&name=%C4%FE%CF%C4&tn=rss";

}else if(title=="乌鲁木齐"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=9001&name=%D0%C2%BD%AE&tn=rss";

}else if(title=="拉萨"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=7915&name=%CE%F7%B2%D8&tn=rss";

}else if(title=="哈尔滨"){

rssUrl = "http://news.baidu.com/n?cmd=7&loc=1967&name=%BA%DA%C1%FA%BD%AD&tn=rss";

}  

listModule = google.mashups.getObjectById('listNewsTop5');

listModule.setData(rssUrl );

}  <!--end of function updataFeed()-->



function updateMap(){
<!--更新地图信息，显示新闻的标题和链接-->

var titleGPathForMap = new GPath("atom:title");

var linkGPathForMap = new GPath("atom:link/@href");
     <!--分别构造标题和链接的对象-->
var output = "";

var size=listModule.getData().size()

var newsTitle;

var newsLink;

for (var i = 0; i < size; i++) {

newsTitle = titleGPathForMap .getValue(listModule.getData().entryAt(i));

newsLink = linkGPathForMap .getValue(listModule.getData().entryAt(i));

output += "<a href=" + newsLink + " target=_blank>" + newsTitle + "</a><br>";

}
<!--分别调用getValue方法获取内容和链接，并按规定的格式显示-->

document.getElementById("td_newsList").innerHTML = output;
<!--调用此方法输出-->  

}


</script>


</gm:page>


